/*
 *  $Id: Unbind.cs 927 2009-12-02 16:12:34Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Affects {
    /// <summary>
    /// Эффект: разбивание оков
    /// Существо игнорирует все эффекты, запрещающие атаковать, но теряет максимальное здоровье в размере числа этих эффектов.
    /// </summary>
    public class Unbind: FlagAffect {
        private int _disablesCount;

        public override string Id {
            get { return "unbind"; }
        }

        public override AffectIcon Icon {
            get { return AffectIcon.Unbind; }
        }

        public override AbstractObject Owner {
            set {
                base.Owner = value;
                Creature cr = value as Creature;
                _disablesCount = cr != null ? cr.AttackDisablesCount : 0;
            }
        }

        public override void SetAffect() {
            base.SetAffect();
            LocalSummary.ChangeMaxHealth(-_disablesCount);
        }
        public override void ResetAffect() {
            base.ResetAffect();
            LocalSummary.ChangeMaxHealth(_disablesCount);
        }
    }
}
